<!DOCTYPE html>
<html>

</head>
<body>
<script type="text/javascript">
    (function(window,document){
        function Clazz(){
            return this.init(arguments);
        }
        Clazz.fn = Clazz.prototype = {
            init:function(opts){
                this.settings = opts;
                return this;
            },
            testInit:function(){
// 直接打印对象
                console.log(this.settings);
// 遍历对象输出
                for (var o in this.settings){
                    console.log(this.settings[o]);
                }
                return this;
            }
        };
        Clazz.addStaticMethod = function(nmSpace,obj,ftn){
            if (!Clazz[nmSpace]){Clazz[nmSpace] = {}}
            for (var i in obj){
                Clazz[nmSpace][i] = obj[i];
            }
            if (ftn) {ftn()}
        }
        Clazz.addObjectMethod = function(nmSpace,obj,ftn){
            if (!Clazz.fn[nmSpace]){Clazz.fn[nmSpace] = {}}
            for (var i in obj){
                Clazz.fn[nmSpace][i] = obj[i];
            }
            if (ftn) {ftn()}
        }
        window.Clazz = Clazz;
    })(window,document,undefined)
    var opts = {
        version:"1.0.0",
        name:"sharpxiajun"
    };
    Clazz.addStaticMethod("myStatic",{
        sClz:"static",
        staticFtn:function(){
            console.log(Clazz["myStatic"].sClz);
        }
    },function(){
        console.log("Add Static Method End!!!!!!!");
    })
    Clazz.addObjectMethod("myFirst",{
        sParam:"sharp",
        ftn01:function(s){
            this.sParam = s;
            return this;
        },
        ftn02:function(){
            console.log("sParam:" + this.sParam);
            return this;
        }
    },function(){
        console.log("Add Object Method End!!!!!!!");
    })
    var $ = new Clazz(opts);
    // 测试一
    $.testInit();
    // 测试二
    console.log($.myFirst.sParam);
    $.myFirst.ftn01("My God!!!").ftn02();
    // 测试三
    console.log(Clazz.myStatic.sClz);
    Clazz.myStatic.staticFtn();
    </body>
    </html>